home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Mousebroken 1.0.1 / source / Modules source ƒ / Generic module / mouse module.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  3.4 KB  |  81 lines  |  [TEXT/KAHL]

  1. /* Generic mouse module -- a foundation for building modules for Mousebroken */
  2. /* version 1.0 -- November 29, 1993 by Mark Pilgrim                          */
  3. /* This module placed in the public domain.                                  */
  4.  
  5. /* Hint: Try removing MacTraps from your project file.  This module needs it only  */
  6. /*       because it uses screenBits & Gestalt.  If your module doesn't do anything */
  7. /*       funky like that, you may not need MacTraps.                               */
  8.  
  9. /* Reminder: Don't forget to customize the resource file to add your own icon,  */
  10. /*           copyright message, module info string, Get Info info strings.      */
  11. /*           The icon is cicn 668 and ICON 668.  The copyright message is       */
  12. /*           STR# 668, string 1.  The module info string is STR# 668, string 2. */
  13. /*           The Get Info strings are vers 1 and vers 2.                        */
  14.  
  15. /* Project Type:        Code Resource                */
  16. /* File Type:            'MMdl'                        */
  17. /* File Creator:        'MBrk'                        */
  18. /* Resource Type:        'vbl '                        */
  19. /* Resource ID:            668                            */
  20. /* Resource name:        (irrelevant)                */
  21. /* Resource attributes:    system heap + locked (0x50)    */
  22. /* Custom header                                    */
  23. /* No multi-segment                                    */
  24.  
  25. #include "Retrace.h"                /* always need */
  26. #include "GestaltEQU.h"                /* delete if don't check environment */
  27.  
  28. extern Boolean CrsrNew : 0x8CE;        /* delete if don't change mouse location */
  29. extern Point MouseOffset : 0x8DA;    /* delete if don't change mouse offset */
  30. extern Point mTemp : 0x828;            /* delete if don't change mouse location */
  31. extern Point RawMouse : 0x82C;        /* delete if don't change mouse location */
  32. extern char keyMap[8] : 0x174;        /* delete if don't check keyboard */
  33.  
  34. Rect            gMainScreenBounds;    /* delete if module doesn't depend on screen bounds */
  35. unsigned long    me;                    /* delete if module has no other global variables */
  36.  
  37. void header(void);                    /* delete if don't use global variables */
  38. void main(void);                    /* always need :) */
  39.  
  40. void header(void)                    /* delete function if don't use global variables */
  41. {
  42.     asm
  43.     {
  44.         dc.l    0                    /* a place to store A4 (to access global variables) */
  45.         move.l a0, d0
  46.         lea header, a0
  47.         jmp main
  48.     }
  49. }
  50.  
  51. #include "SetUpA4.h"                /* delete if don't use global variables */
  52.  
  53. void main(void)                        /* the main thing -- always need */
  54. {
  55.     VBLTask*        myVBL;            /* pointer to VBL structure -- always need */
  56.     long            gestalt_temp;    /* delete if don't check environment */
  57.     OSErr            isHuman;        /* delete if don't check environment */
  58.     
  59.     RememberA0();                    /* delete if don't use global variables */
  60.     SetUpA4();                        /* delete if don't use global variables */
  61.     
  62.     asm                                /* move VBL structure pointer into local variable */
  63.     {                                /* always need this so we can set vblCount later */
  64.         move.l d0, myVBL            /* (see below) */
  65.     }
  66.     
  67.     if (me != 'MMdl')                /* delete "if" statement if don't need initialization */
  68.     {
  69.         isHuman = Gestalt(gestaltQuickdrawVersion, &gestalt_temp);    /* Quickdraw version? */
  70.         gMainScreenBounds=(isHuman || (gestalt_temp < gestalt8BitQD)) ? screenBits.bounds :
  71.             (**GetMainDevice()).gdRect;    /* delete if don't need screen bounds */
  72.         me = 'MMdl';                /* need so we don't re-initialize */
  73.     }
  74.     
  75.     /* put lots o' neat stuff here */
  76.     
  77.     CrsrNew = TRUE;                    /* to redraw mouse; use only if mouse location changes */
  78.     myVBL->vblCount = 1;            /* how many ticks until this code gets called again */
  79.     RestoreA4();                    /* delete if don't use global variables */
  80. }
  81.